﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Net.Mail;
using System.Net;

/// <summary>
/// Summary description for UtilityLib
/// </summary>
public static class UtilityLib
{
    public static void sentmail(String mailto, String user, String pass)
    {
        MailMessage mm = new MailMessage();
        mm.From = new MailAddress(Constant.EMAIL_ADMIN, "Admin Techdata");
        mm.To.Add(new MailAddress(mailto));
        mm.Subject = "Forgot Password for username " + user + " at Techdata";
        mm.IsBodyHtml = true;
        mm.Body = "<div style=\"width:600px; background-color:#fff; margin:0 auto; float:left; margin-left:10px;text-align:justify;\">" +
                    "<img src=\"http://techdata.com.vn/techdata/images/logo copy.jpg\" style=\"margin:10px 0;\" /><br />" +
                    "<p style=\"width:600px; text-align:justify;margin:0px; margin-top:20px;float:left;\">You or someone has been require to get new password:</p>" +
                    "<p style=\"width:600px; text-align:justify;margin:0px; margin-top:20px;float:left;\">New account information are:</p>" +
                    "<p style=\"width:600px; text-align:justify;margin:0px; margin-top:20px;float:left;\">Username: <strong>" + user + "</strong></p>" +
                    "<p style=\"width:600px; text-align:justify;margin:0px; margin-top:20px;float:left;\">Password: <strong>" + pass + "</strong></p>" +
                    "<p>-----------------------------------------------------------------------</p>" +
                    "<br/><br/><br/><p>If you didn't require, please contact Techdata Support Team to get more information.</p>" +
                    "<p><span class=\"style1\">Techdata Administrator Team</span><br />" +
                    "Email: <a href=\"mailto:info@techdata.com.vn\">info@techdata.com.vn</a><br />" +
                    "Phone: 0907246145<br />" +
                    "Website: <a href=\"http://techdata.com.vn\">techdata.com.vn</a></p>" +
                    "<p>Thanks for use our service!</p>" +
                    "<p style=\"width:600px; text-align:justify;margin:0px; margin-top:20px;float:left;\">&nbsp;</p>" +
                    "<p style=\"width:600px; text-align:justify;margin:0px; float:left;\">&nbsp;</p>" +
                    "<br />" +
                "</div>";
        //mm.Body = "abc";
        SmtpClient sc = new SmtpClient();
        sc.Host = "smtp.gmail.com";
        sc.Port = 587;
        sc.Credentials = new NetworkCredential(Constant.EMAIL_ADMIN, Constant.PASS_EMAIL_ADMIN);
        sc.EnableSsl = true;
        sc.DeliveryMethod = SmtpDeliveryMethod.Network;
        sc.Send(mm);
    }
    
}
